<?php
require_once("lib/autoload.php");

$method = $_SERVER['REQUEST_METHOD'];
if ($method == "POST") {
    #header('Content-type: application/json');
    
    $arguments = $_POST;
    extract($arguments );
    
    if (isset($actionId) && isset($user) && isset($comment) ) {
        $dc = new DataController();
        $dc->connect();
        $commentId = $dc->saveComment($actionId, $user, $comment);
        if ($commentId > 0) {
            print "{success: 'true', commentId: $commentId}";
        }
        else {
            print "{succes: 'false'}";
        }
        $dc->disconnect();
    }
    else {
        print "{succes: 'false'}";
    }
}
else {
    header('Allow: POST', true, 405);
}
?>